summaryrefslogtreecommitdiff
path: root/ui/routes/(login)/invite/[invite]/+page.svelte
blob: eea05fc37e971685f2f9adc2c1a6621558261de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<script>
    import { goto } from '$app/navigation';
    import { page } from '$app/stores';
    import { acceptInvite } from '$lib/apiServer';

    $: inviteId = $page?.params?.invite;
    $: invite = $page.data;

    import LogIn from '$lib/components/LogIn.svelte';

    let disabled;
    let username;
    let password;

    async function onSubmit() {
        disabled = true;
        const response = await acceptInvite(inviteId, username, password);
        if (200 <= response.status && response.status < 300) {
            username = '';
            password = '';
            goto('/');
        }
        disabled = false;
    }
</script>

<p>Hi there! {invite.issuer.name} invites you to the conversation.</p>
<LogIn bind:disabled bind:username bind:password on:submit={onSubmit} />